NexusPi Git Node
lib/microReticulum/src/Destination.cpp copilot/add-rtnode-configuration-options (9529fa8a) Text, 19.00 KB
Tff7b72#Tff7b72include T8b949e"Destination.h"
Tff7b72#Tff7b72include T8b949e"Transport.h"
Tff7b72#Tff7b72include T8b949e"Interface.h"
Tff7b72#Tff7b72include T8b949e"Packet.h"
Tff7b72#Tff7b72include T8b949e"Log.h"
Tff7b72#Tff7b72include T8b949e<vector>
Tff7b72#Tff7b72include T8b949e<time.h>
Tff7b72#Tff7b72include T8b949e<string.h>
Tff7b72using Tff7b72namespace T7ee787RNSTb4b4b4;
Tff7b72using Tff7b72namespace T7ee787RNSTff7b72:Tff7b72:T7ee787TypeTff7b72:Tff7b72:T7ee787DestinationTb4b4b4;
Tff7b72using Tff7b72namespace T7ee787RNSTff7b72:Tff7b72:T7ee787UtilitiesTb4b4b4;
Te6edf3DestinationTff7b72:Tff7b72:Te6edf3DestinationTb4b4b4(Tff7b72const Te6edf3IdentityTff7b72& Te6edf3identityTb4b4b4, Tff7b72const Te6edf3directions Te6edf3directionTb4b4b4, Tff7b72const Te6edf3types Te6edf3typeTb4b4b4, Tff7b72const Tffa657charTff7b72* Te6edf3app_nameTb4b4b4, Tff7b72const Tffa657charTff7b72* Te6edf3aspectsTb4b4b4) Tff7b72: Te6edf3_objectTb4b4b4(Tff7b72new Te6edf3ObjectTb4b4b4(Te6edf3identityTb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3assertTb4b4b4(Te6edf3_objectTb4b4b4)Tb4b4b4;
Te6edf3MEMTb4b4b4(Ta5d6ff"Ta5d6ffDestination object creating..., this: Ta5d6ff" Tff7b72+ Te6edf3stdTff7b72:Tff7b72:Te6edf3to_stringTb4b4b4(Tb4b4b4(Tffa657uintptr_tTb4b4b4)Tff7b72thisTb4b4b4) Tff7b72+ Ta5d6ff"Ta5d6ff, data: Ta5d6ff" Tff7b72+ Te6edf3stdTff7b72:Tff7b72:Te6edf3to_stringTb4b4b4(Tb4b4b4(Tffa657uintptr_tTb4b4b4)Te6edf3_objectTb4b4b4.Te6edf3getTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4)Tb4b4b4;
T8b949e// Check input values and build name string
Tff7b72if Tb4b4b4(Te6edf3strchrTb4b4b4(Te6edf3app_nameTb4b4b4, Ta5d6ff'Ta5d6ff.Ta5d6ff'Tb4b4b4) Tff7b72!Tff7b72= Tffa657nullptrTb4b4b4) Tb4b4b4{
Tff7b72throw Te6edf3stdTff7b72:Tff7b72:Te6edf3invalid_argumentTb4b4b4(Ta5d6ff"Ta5d6ffDots can't be used in app namesTa5d6ff"Tb4b4b4)Tb4b4b4;
Tb4b4b4}
T8b949e//TRACE("Destination::Destination: app name: " + std::string(app_name));
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_type Tff7b72= Te6edf3typeTb4b4b4;
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_direction Tff7b72= Te6edf3directionTb4b4b4;
Te6edf3stdTff7b72:Tff7b72:Te6edf3string Td2a8fffullaspectsTb4b4b4(Te6edf3aspectsTb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Tff7b72!Te6edf3identity Tff7b72&Tff7b72& Te6edf3direction Tff7b72=Tff7b72= Te6edf3IN Tff7b72&Tff7b72& Te6edf3_objectTff7b72-Tff7b72>Te6edf3_type Tff7b72!Tff7b72= Te6edf3PLAINTb4b4b4) Tb4b4b4{
Te6edf3TRACETb4b4b4(Ta5d6ff"Ta5d6ffDestination::Destination: identity not provided, creating new oneTa5d6ff"Tb4b4b4)Tb4b4b4;
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identity Tff7b72= Te6edf3IdentityTb4b4b4(Tb4b4b4)Tb4b4b4;
T8b949e// CBA TODO determine why identity.hexhash is added both here and by expand_name called below
Te6edf3fullaspects Tff7b72+Tff7b72= Ta5d6ff"Ta5d6ff.Ta5d6ff" Tff7b72+ Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4.Te6edf3hexhashTb4b4b4(Tb4b4b4)Tb4b4b4;
Tb4b4b4}
T8b949e//TRACE("Destination::Destination: full aspects: " + fullaspects);
Tff7b72if Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identity Tff7b72&Tff7b72& Te6edf3_objectTff7b72-Tff7b72>Te6edf3_type Tff7b72=Tff7b72= Te6edf3PLAINTb4b4b4) Tb4b4b4{
Tff7b72throw Te6edf3stdTff7b72:Tff7b72:Te6edf3invalid_argumentTb4b4b4(Ta5d6ff"Ta5d6ffSelected destination type PLAIN cannot hold an identityTa5d6ff"Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_name Tff7b72= Te6edf3expand_nameTb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4, Te6edf3app_nameTb4b4b4, Te6edf3fullaspectsTb4b4b4.Te6edf3c_strTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4;
T8b949e//TRACE("Destination::Destination: name: " + _object->_name);
T8b949e// Generate the destination address hash
T8b949e//TRACE("Destination::Destination: creating hash...");
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_hash Tff7b72= Te6edf3hashTb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4, Te6edf3app_nameTb4b4b4, Te6edf3fullaspectsTb4b4b4.Te6edf3c_strTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4;
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_hexhash Tff7b72= Te6edf3_objectTff7b72-Tff7b72>Te6edf3_hashTb4b4b4.Te6edf3toHexTb4b4b4(Tb4b4b4)Tb4b4b4;
Te6edf3TRACETb4b4b4(Ta5d6ff"Ta5d6ffDestination::Destination: hash: Ta5d6ff" Tff7b72+ Te6edf3_objectTff7b72-Tff7b72>Te6edf3_hashTb4b4b4.Te6edf3toHexTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4;
T8b949e//TRACE("Destination::Destination: creating name hash...");
T8b949e//p self.name_hash = RNS.Identity.full_hash(self.expand_name(None, app_name, *aspects).encode("utf-8"))[:(RNS.Identity.NAME_HASH_LENGTH//8)]
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_name_hash Tff7b72= Te6edf3name_hashTb4b4b4(Te6edf3app_nameTb4b4b4, Te6edf3aspectsTb4b4b4)Tb4b4b4;
T8b949e//TRACE("Destination::Destination: name hash: " + _object->_name_hash.toHex());
T8b949e//TRACE("Destination::Destination: calling register_destination");
Te6edf3TransportTff7b72:Tff7b72:Te6edf3register_destinationTb4b4b4(Tff7b72*Tff7b72thisTb4b4b4)Tb4b4b4;
Te6edf3MEMTb4b4b4(Ta5d6ff"Ta5d6ffDestination object created, this: Ta5d6ff" Tff7b72+ Te6edf3stdTff7b72:Tff7b72:Te6edf3to_stringTb4b4b4(Tb4b4b4(Tffa657uintptr_tTb4b4b4)Tff7b72thisTb4b4b4) Tff7b72+ Ta5d6ff"Ta5d6ff, data: Ta5d6ff" Tff7b72+ Te6edf3stdTff7b72:Tff7b72:Te6edf3to_stringTb4b4b4(Tb4b4b4(Tffa657uintptr_tTb4b4b4)Te6edf3_objectTb4b4b4.Te6edf3getTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Te6edf3DestinationTff7b72:Tff7b72:Te6edf3DestinationTb4b4b4(Tff7b72const Te6edf3IdentityTff7b72& Te6edf3identityTb4b4b4, Tff7b72const Te6edf3TypeTff7b72:Tff7b72:Te6edf3DestinationTff7b72:Tff7b72:Te6edf3directions Te6edf3directionTb4b4b4, Tff7b72const Te6edf3TypeTff7b72:Tff7b72:Te6edf3DestinationTff7b72:Tff7b72:Te6edf3types Te6edf3typeTb4b4b4, Tff7b72const Te6edf3BytesTff7b72& Te6edf3hashTb4b4b4) Tff7b72: Te6edf3_objectTb4b4b4(Tff7b72new Te6edf3ObjectTb4b4b4(Te6edf3identityTb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3assertTb4b4b4(Te6edf3_objectTb4b4b4)Tb4b4b4;
Te6edf3MEMTb4b4b4(Ta5d6ff"Ta5d6ffDestination object creating..., this: Ta5d6ff" Tff7b72+ Te6edf3stdTff7b72:Tff7b72:Te6edf3to_stringTb4b4b4(Tb4b4b4(Tffa657uintptr_tTb4b4b4)Tff7b72thisTb4b4b4) Tff7b72+ Ta5d6ff"Ta5d6ff, data: Ta5d6ff" Tff7b72+ Te6edf3stdTff7b72:Tff7b72:Te6edf3to_stringTb4b4b4(Tb4b4b4(Tffa657uintptr_tTb4b4b4)Te6edf3_objectTb4b4b4.Te6edf3getTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4)Tb4b4b4;
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_type Tff7b72= Te6edf3typeTb4b4b4;
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_direction Tff7b72= Te6edf3directionTb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identity Tff7b72&Tff7b72& Te6edf3_objectTff7b72-Tff7b72>Te6edf3_type Tff7b72=Tff7b72= Te6edf3PLAINTb4b4b4) Tb4b4b4{
Tff7b72throw Te6edf3stdTff7b72:Tff7b72:Te6edf3invalid_argumentTb4b4b4(Ta5d6ff"Ta5d6ffSelected destination type PLAIN cannot hold an identityTa5d6ff"Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_hash Tff7b72= Te6edf3hashTb4b4b4;
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_hexhash Tff7b72= Te6edf3_objectTff7b72-Tff7b72>Te6edf3_hashTb4b4b4.Te6edf3toHexTb4b4b4(Tb4b4b4)Tb4b4b4;
Te6edf3TRACETb4b4b4(Ta5d6ff"Ta5d6ffDestination::Destination: hash: Ta5d6ff" Tff7b72+ Te6edf3_objectTff7b72-Tff7b72>Te6edf3_hashTb4b4b4.Te6edf3toHexTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4;
T8b949e//TRACE("Destination::Destination: creating name hash...");
T8b949e//p self.name_hash = RNS.Identity.full_hash(self.expand_name(None, app_name, *aspects).encode("utf-8"))[:(RNS.Identity.NAME_HASH_LENGTH//8)]
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_name_hash Tff7b72= Te6edf3name_hashTb4b4b4(Ta5d6ff"Ta5d6ffunknownTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ffunknownTa5d6ff"Tb4b4b4)Tb4b4b4;
T8b949e//TRACE("Destination::Destination: name hash: " + _object->_name_hash.toHex());
T8b949e//TRACE("Destination::Destination: calling register_destination");
Te6edf3TransportTff7b72:Tff7b72:Te6edf3register_destinationTb4b4b4(Tff7b72*Tff7b72thisTb4b4b4)Tb4b4b4;
Te6edf3MEMTb4b4b4(Ta5d6ff"Ta5d6ffDestination object created, this: Ta5d6ff" Tff7b72+ Te6edf3stdTff7b72:Tff7b72:Te6edf3to_stringTb4b4b4(Tb4b4b4(Tffa657uintptr_tTb4b4b4)Tff7b72thisTb4b4b4) Tff7b72+ Ta5d6ff"Ta5d6ff, data: Ta5d6ff" Tff7b72+ Te6edf3stdTff7b72:Tff7b72:Te6edf3to_stringTb4b4b4(Tb4b4b4(Tffa657uintptr_tTb4b4b4)Te6edf3_objectTb4b4b4.Te6edf3getTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4)Tb4b4b4;
Tb4b4b4}
T8b949e/*virtual*/ Te6edf3DestinationTff7b72:Tff7b72:Tff7b72~Te6edf3DestinationTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3MEMTb4b4b4(Ta5d6ff"Ta5d6ffDestination object destroyed, this: Ta5d6ff" Tff7b72+ Te6edf3stdTff7b72:Tff7b72:Te6edf3to_stringTb4b4b4(Tb4b4b4(Tffa657uintptr_tTb4b4b4)Tff7b72thisTb4b4b4) Tff7b72+ Ta5d6ff"Ta5d6ff, data: Ta5d6ff" Tff7b72+ Te6edf3stdTff7b72:Tff7b72:Te6edf3to_stringTb4b4b4(Tb4b4b4(Tffa657uintptr_tTb4b4b4)Te6edf3_objectTb4b4b4.Te6edf3getTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3_object Tff7b72&Tff7b72& Te6edf3_objectTb4b4b4.Te6edf3use_countTb4b4b4(Tb4b4b4) Tff7b72=Tff7b72= T79c0ff1Tb4b4b4) Tb4b4b4{
Te6edf3MEMTb4b4b4(Ta5d6ff"Ta5d6ffDestination object has last data referenceTa5d6ff"Tb4b4b4)Tb4b4b4;
T8b949e// CBA Can't call deregister_destination here because it's possible (likely even) that Destination
T8b949e// is being destructed from that same collection which will result in a llop and memory errors.
T8b949e//TRACE("Destination::~Destination: calling deregister_destination");
T8b949e//Transport::deregister_destination(*this);
Tb4b4b4}
Tb4b4b4}
T8b949e/*
:returns: A destination name in adressable hash form, for an app_name and a number of aspects.
*/
T8b949e/*static*/ Te6edf3Bytes Te6edf3DestinationTff7b72:Tff7b72:Te6edf3hashTb4b4b4(Tff7b72const Te6edf3IdentityTff7b72& Te6edf3identityTb4b4b4, Tff7b72const Tffa657charTff7b72* Te6edf3app_nameTb4b4b4, Tff7b72const Tffa657charTff7b72* Te6edf3aspectsTb4b4b4) Tb4b4b4{
T8b949e//p name_hash = Identity::full_hash(Destination.expand_name(None, app_name, *aspects).encode("utf-8"))[:(RNS.Identity.NAME_HASH_LENGTH//8)]
T8b949e//p addr_hash_material = name_hash
Te6edf3Bytes Te6edf3addr_hash_material Tff7b72= Te6edf3name_hashTb4b4b4(Te6edf3app_nameTb4b4b4, Te6edf3aspectsTb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3identityTb4b4b4) Tb4b4b4{
Te6edf3addr_hash_material Tff7b72<Tff7b72< Te6edf3identityTb4b4b4.Te6edf3hashTb4b4b4(Tb4b4b4)Tb4b4b4;
Tb4b4b4}
T8b949e//p return RNS.Identity.full_hash(addr_hash_material)[:RNS.Reticulum.TRUNCATED_HASHLENGTH//8]
T8b949e// CBA TODO valid alternative?
T8b949e//return Identity::full_hash(addr_hash_material).left(Type::Reticulum::TRUNCATED_HASHLENGTH/8);
Tff7b72return Te6edf3IdentityTff7b72:Tff7b72:Te6edf3truncated_hashTb4b4b4(Te6edf3addr_hash_materialTb4b4b4)Tb4b4b4;
Tb4b4b4}
T8b949e/*
:returns: A name in hash form, for an app_name and a number of aspects.
*/
T8b949e/*static*/ Te6edf3Bytes Te6edf3DestinationTff7b72:Tff7b72:Te6edf3name_hashTb4b4b4(Tff7b72const Tffa657charTff7b72* Te6edf3app_nameTb4b4b4, Tff7b72const Tffa657charTff7b72* Te6edf3aspectsTb4b4b4) Tb4b4b4{
T8b949e//p name_hash = Identity::full_hash(Destination.expand_name(None, app_name, *aspects).encode("utf-8"))[:(RNS.Identity.NAME_HASH_LENGTH//8)]
Tff7b72return Te6edf3IdentityTff7b72:Tff7b72:Te6edf3full_hashTb4b4b4(Te6edf3expand_nameTb4b4b4(Tb4b4b4{Te6edf3TypeTff7b72:Tff7b72:Te6edf3NONETb4b4b4}Tb4b4b4, Te6edf3app_nameTb4b4b4, Te6edf3aspectsTb4b4b4)Tb4b4b4)Tb4b4b4.Te6edf3leftTb4b4b4(Te6edf3TypeTff7b72:Tff7b72:Te6edf3IdentityTff7b72:Tff7b72:Te6edf3NAME_HASH_LENGTHTff7b72/T79c0ff8Tb4b4b4)Tb4b4b4;
Tb4b4b4}
T8b949e/*
:returns: A tuple containing the app name and a list of aspects, for a full-name string.
*/
T8b949e/*static*/ Te6edf3stdTff7b72:Tff7b72:Te6edf3vectorTff7b72<Te6edf3stdTff7b72:Tff7b72:Te6edf3stringTff7b72> Te6edf3DestinationTff7b72:Tff7b72:Te6edf3app_and_aspects_from_nameTb4b4b4(Tff7b72const Tffa657charTff7b72* Te6edf3full_nameTb4b4b4) Tb4b4b4{
T8b949e//p components = full_name.split(".")
T8b949e//p return (components[0], components[1:])
Te6edf3stdTff7b72:Tff7b72:Te6edf3vectorTff7b72<Te6edf3stdTff7b72:Tff7b72:Te6edf3stringTff7b72> Te6edf3componentsTb4b4b4;
Te6edf3stdTff7b72:Tff7b72:Te6edf3string Td2a8ffnameTb4b4b4(Te6edf3full_nameTb4b4b4)Tb4b4b4;
Te6edf3stdTff7b72:Tff7b72:Tffa657size_t Te6edf3pos Tff7b72= Te6edf3nameTb4b4b4.Te6edf3findTb4b4b4(Ta5d6ff'Ta5d6ff.Ta5d6ff'Tb4b4b4)Tb4b4b4;
Te6edf3componentsTb4b4b4.Te6edf3push_backTb4b4b4(Te6edf3nameTb4b4b4.Te6edf3substrTb4b4b4(T79c0ff0Tb4b4b4, Te6edf3posTb4b4b4)Tb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3pos Tff7b72!Tff7b72= Te6edf3stdTff7b72:Tff7b72:Te6edf3stringTff7b72:Tff7b72:Te6edf3nposTb4b4b4) Tb4b4b4{
Te6edf3componentsTb4b4b4.Te6edf3push_backTb4b4b4(Te6edf3nameTb4b4b4.Te6edf3substrTb4b4b4(Te6edf3posTff7b72+T79c0ff1Tb4b4b4)Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Tff7b72return Te6edf3componentsTb4b4b4;
Tb4b4b4}
T8b949e/*
:returns: A destination name in adressable hash form, for a full name string and Identity instance.
*/
T8b949e/*static*/ Te6edf3Bytes Te6edf3DestinationTff7b72:Tff7b72:Te6edf3hash_from_name_and_identityTb4b4b4(Tff7b72const Tffa657charTff7b72* Te6edf3full_nameTb4b4b4, Tff7b72const Te6edf3IdentityTff7b72& Te6edf3identityTb4b4b4) Tb4b4b4{
T8b949e//p app_name, aspects = Destination.app_and_aspects_from_name(full_name)
T8b949e//p return Destination.hash(identity, app_name, *aspects)
Te6edf3stdTff7b72:Tff7b72:Te6edf3vectorTff7b72<Te6edf3stdTff7b72:Tff7b72:Te6edf3stringTff7b72> Te6edf3components Tff7b72= Te6edf3app_and_aspects_from_nameTb4b4b4(Te6edf3full_nameTb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3componentsTb4b4b4.Te6edf3sizeTb4b4b4(Tb4b4b4) Tff7b72=Tff7b72= T79c0ff0Tb4b4b4) Tb4b4b4{
Tff7b72return Tb4b4b4{Te6edf3BytesTff7b72:Tff7b72:Te6edf3NONETb4b4b4}Tb4b4b4;
Tb4b4b4}
Tff7b72if Tb4b4b4(Te6edf3componentsTb4b4b4.Te6edf3sizeTb4b4b4(Tb4b4b4) Tff7b72=Tff7b72= T79c0ff1Tb4b4b4) Tb4b4b4{
Tff7b72return Te6edf3hashTb4b4b4(Te6edf3identityTb4b4b4, Te6edf3componentsTb4b4b4[T79c0ff0Tb4b4b4]Tb4b4b4.Te6edf3c_strTb4b4b4(Tb4b4b4)Tb4b4b4, Ta5d6ff"Ta5d6ff"Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Tff7b72return Te6edf3hashTb4b4b4(Te6edf3identityTb4b4b4, Te6edf3componentsTb4b4b4[T79c0ff0Tb4b4b4]Tb4b4b4.Te6edf3c_strTb4b4b4(Tb4b4b4)Tb4b4b4, Te6edf3componentsTb4b4b4[T79c0ff1Tb4b4b4]Tb4b4b4.Te6edf3c_strTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4;
Tb4b4b4}
T8b949e/*
:returns: A string containing the full human-readable name of the destination, for an app_name and a number of aspects.
*/
T8b949e/*static*/ Te6edf3stdTff7b72:Tff7b72:Te6edf3string Te6edf3DestinationTff7b72:Tff7b72:Te6edf3expand_nameTb4b4b4(Tff7b72const Te6edf3IdentityTff7b72& Te6edf3identityTb4b4b4, Tff7b72const Tffa657charTff7b72* Te6edf3app_nameTb4b4b4, Tff7b72const Tffa657charTff7b72* Te6edf3aspectsTb4b4b4) Tb4b4b4{
Tff7b72if Tb4b4b4(Te6edf3strchrTb4b4b4(Te6edf3app_nameTb4b4b4, Ta5d6ff'Ta5d6ff.Ta5d6ff'Tb4b4b4) Tff7b72!Tff7b72= Tffa657nullptrTb4b4b4) Tb4b4b4{
Tff7b72throw Te6edf3stdTff7b72:Tff7b72:Te6edf3invalid_argumentTb4b4b4(Ta5d6ff"Ta5d6ffDots can't be used in app namesTa5d6ff"Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Te6edf3stdTff7b72:Tff7b72:Te6edf3string Te6edf3nameTb4b4b4(Te6edf3app_nameTb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3aspects Tff7b72!Tff7b72= Tffa657nullptrTb4b4b4) Tb4b4b4{
Te6edf3name Tff7b72+Tff7b72= Te6edf3stdTff7b72:Tff7b72:Te6edf3stringTb4b4b4(Ta5d6ff"Ta5d6ff.Ta5d6ff"Tb4b4b4) Tff7b72+ Te6edf3aspectsTb4b4b4;
Tb4b4b4}
Tff7b72if Tb4b4b4(Te6edf3identityTb4b4b4) Tb4b4b4{
Te6edf3name Tff7b72+Tff7b72= Ta5d6ff"Ta5d6ff.Ta5d6ff" Tff7b72+ Te6edf3identityTb4b4b4.Te6edf3hexhashTb4b4b4(Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Tff7b72return Te6edf3nameTb4b4b4;
Tb4b4b4}
T8b949e/*
Creates an announce packet for this destination and broadcasts it on all
relevant interfaces. Application specific data can be added to the announce.
:param app_data: *bytes* containing the app_data.
:param path_response: Internal flag used by :ref:`RNS.Transport<api-transport>`. Ignore.
*/
T8b949e//Packet Destination::announce(const Bytes& app_data /*= {}*/, bool path_response /*= false*/, const Interface& attached_interface /*= {Type::NONE}*/, const Bytes& tag /*= {}*/, bool send /*= true*/) {
Te6edf3Packet Te6edf3DestinationTff7b72:Tff7b72:Te6edf3announceTb4b4b4(Tff7b72const Te6edf3BytesTff7b72& Te6edf3app_dataTb4b4b4, Tffa657bool Te6edf3path_responseTb4b4b4, Tff7b72const Te6edf3InterfaceTff7b72& Te6edf3attached_interfaceTb4b4b4, Tff7b72const Te6edf3BytesTff7b72& Te6edf3tag T8b949e/*= {}*/Tb4b4b4, Tffa657bool Te6edf3send T8b949e/*= true*/Tb4b4b4) Tb4b4b4{
Te6edf3assertTb4b4b4(Te6edf3_objectTb4b4b4)Tb4b4b4;
Te6edf3TRACETb4b4b4(Ta5d6ff"Ta5d6ffDestination::announce: announcing destination...Ta5d6ff"Tb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_type Tff7b72!Tff7b72= Te6edf3SINGLETb4b4b4) Tb4b4b4{
Tff7b72throw Te6edf3stdTff7b72:Tff7b72:Te6edf3invalid_argumentTb4b4b4(Ta5d6ff"Ta5d6ffOnly SINGLE destination types can be announcedTa5d6ff"Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Tff7b72if Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_direction Tff7b72!Tff7b72= Te6edf3INTb4b4b4) Tb4b4b4{
Tff7b72throw Te6edf3stdTff7b72:Tff7b72:Te6edf3invalid_argumentTb4b4b4(Ta5d6ff"Ta5d6ffOnly IN destination types can be announcedTa5d6ff"Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Tffa657double Te6edf3now Tff7b72= Te6edf3OSTff7b72:Tff7b72:Te6edf3timeTb4b4b4(Tb4b4b4)Tb4b4b4;
Tff7b72auto Te6edf3it Tff7b72= Te6edf3_objectTff7b72-Tff7b72>Te6edf3_path_responsesTb4b4b4.Te6edf3beginTb4b4b4(Tb4b4b4)Tb4b4b4;
Tff7b72while Tb4b4b4(Te6edf3it Tff7b72!Tff7b72= Te6edf3_objectTff7b72-Tff7b72>Te6edf3_path_responsesTb4b4b4.Te6edf3endTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{
T8b949e// vector
T8b949e//Response& entry = *it;
T8b949e// map
Te6edf3PathResponseTff7b72& Te6edf3entry Tff7b72= Tb4b4b4(Tff7b72*Te6edf3itTb4b4b4)Tb4b4b4.Te6edf3secondTb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3now Tff7b72> Tb4b4b4(Te6edf3entryTb4b4b4.Te6edf3first Tff7b72+ Te6edf3PR_TAG_WINDOWTb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3it Tff7b72= Te6edf3_objectTff7b72-Tff7b72>Te6edf3_path_responsesTb4b4b4.Te6edf3eraseTb4b4b4(Te6edf3itTb4b4b4)Tb4b4b4;
Tb4b4b4}
Tff7b72else Tb4b4b4{
Tff7b72+Tff7b72+Te6edf3itTb4b4b4;
Tb4b4b4}
Tb4b4b4}
Te6edf3Bytes Te6edf3announce_dataTb4b4b4;
T8b949e/*
// CBA TEST
TRACE("Destination::announce: performing path test...");
TRACE("Destination::announce: inserting path...");
_object->_path_responses.insert({Bytes("foo_tag"), {0, Bytes("this is foo tag")}});
TRACE("Destination::announce: inserting path...");
_object->_path_responses.insert({Bytes("test_tag"), {0, Bytes("this is test tag")}});
if (path_response) {
TRACE("Destination::announce: path_response is true");
}
if (!tag.empty()) {
TRACE("Destination::announce: tag is specified");
std::string tagstr((const char*)tag.data(), tag.size());
DEBUG(std::string("Destination::announce: tag: ") + tagstr);
DEBUG(std::string("Destination::announce: tag len: ") + std::to_string(tag.size()));
TRACE("Destination::announce: searching for tag...");
if (_object->_path_responses.find(tag) != _object->_path_responses.end()) {
TRACE("Destination::announce: found tag in _path_responses");
DEBUG(std::string("Destination::announce: data: ") +_object->_path_responses[tag].second.toString());
}
else {
TRACE("Destination::announce: tag not found in _path_responses");
}
}
TRACE("Destination::announce: path test finished");
*/
Tff7b72if Tb4b4b4(Te6edf3path_response Tff7b72&Tff7b72& Tff7b72!Te6edf3tagTb4b4b4.Te6edf3emptyTb4b4b4(Tb4b4b4) Tff7b72&Tff7b72& Te6edf3_objectTff7b72-Tff7b72>Te6edf3_path_responsesTb4b4b4.Te6edf3findTb4b4b4(Te6edf3tagTb4b4b4) Tff7b72!Tff7b72= Te6edf3_objectTff7b72-Tff7b72>Te6edf3_path_responsesTb4b4b4.Te6edf3endTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{
T8b949e// This code is currently not used, since Transport will block duplicate
T8b949e// path requests based on tags. When multi-path support is implemented in
T8b949e// Transport, this will allow Transport to detect redundant paths to the
T8b949e// same destination, and select the best one based on chosen criteria,
T8b949e// since it will be able to detect that a single emitted announce was
T8b949e// received via multiple paths. The difference in reception time will
T8b949e// potentially also be useful in determining characteristics of the
T8b949e// multiple available paths, and to choose the best one.
T8b949e//z TRACE("Using cached announce data for answering path request with tag "+RNS.prettyhexrep(tag));
Te6edf3announce_data Tff7b72<Tff7b72< Te6edf3_objectTff7b72-Tff7b72>Te6edf3_path_responsesTb4b4b4[Te6edf3tagTb4b4b4]Tb4b4b4.Te6edf3secondTb4b4b4;
Tb4b4b4}
Tff7b72else Tb4b4b4{
Te6edf3Bytes Te6edf3destination_hash Tff7b72= Te6edf3_objectTff7b72-Tff7b72>Te6edf3_hashTb4b4b4;
T8b949e//p random_hash = Identity::get_random_hash()[0:5] << int(time.time()).to_bytes(5, "big")
T8b949e// CBA TODO add in time to random hash
Te6edf3Bytes Te6edf3random_hash Tff7b72= Te6edf3CryptographyTff7b72:Tff7b72:Te6edf3randomTb4b4b4(Te6edf3TypeTff7b72:Tff7b72:Te6edf3IdentityTff7b72:Tff7b72:Te6edf3RANDOM_HASH_LENGTHTff7b72/T79c0ff8Tb4b4b4)Tb4b4b4;
Te6edf3Bytes Td2a8ffnew_app_dataTb4b4b4(Te6edf3app_dataTb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3new_app_dataTb4b4b4.Te6edf3emptyTb4b4b4(Tb4b4b4) Tff7b72&Tff7b72& Tff7b72!Te6edf3_objectTff7b72-Tff7b72>Te6edf3_default_app_dataTb4b4b4.Te6edf3emptyTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3new_app_data Tff7b72= Te6edf3_objectTff7b72-Tff7b72>Te6edf3_default_app_dataTb4b4b4;
Tb4b4b4}
Te6edf3Bytes Te6edf3signed_dataTb4b4b4;
T8b949e//TRACE("Destination::announce: hash: " + _object->_hash.toHex());
T8b949e//TRACE("Destination::announce: public key: " + _object->_identity.get_public_key().toHex());
T8b949e//TRACE("Destination::announce: name hash: " + _object->_name_hash.toHex());
T8b949e//TRACE("Destination::announce: random hash: " + random_hash.toHex());
T8b949e//TRACE("Destination::announce: app data: " + new_app_data.toHex());
T8b949e//TRACE("Destination::announce: app data text:" + new_app_data.toString());
Te6edf3signed_data Tff7b72<Tff7b72< Te6edf3_objectTff7b72-Tff7b72>Te6edf3_hash Tff7b72<Tff7b72< Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4.Te6edf3get_public_keyTb4b4b4(Tb4b4b4) Tff7b72<Tff7b72< Te6edf3_objectTff7b72-Tff7b72>Te6edf3_name_hash Tff7b72<Tff7b72< Te6edf3random_hashTb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3new_app_dataTb4b4b4) Tb4b4b4{
Te6edf3signed_data Tff7b72<Tff7b72< Te6edf3new_app_dataTb4b4b4;
Tb4b4b4}
T8b949e//TRACE("Destination::announce: signed data: " + signed_data.toHex());
Te6edf3Bytes Te6edf3signatureTb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4.Te6edf3signTb4b4b4(Te6edf3signed_dataTb4b4b4)Tb4b4b4)Tb4b4b4;
T8b949e//TRACE("Destination::announce: signature: " + signature.toHex());
Te6edf3announce_data Tff7b72<Tff7b72< Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4.Te6edf3get_public_keyTb4b4b4(Tb4b4b4) Tff7b72<Tff7b72< Te6edf3_objectTff7b72-Tff7b72>Te6edf3_name_hash Tff7b72<Tff7b72< Te6edf3random_hash Tff7b72<Tff7b72< Te6edf3signatureTb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3new_app_dataTb4b4b4) Tb4b4b4{
Te6edf3announce_data Tff7b72<Tff7b72< Te6edf3new_app_dataTb4b4b4;
Tb4b4b4}
T8b949e// CBA ACCUMULATES
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_path_responsesTb4b4b4.Te6edf3insertTb4b4b4(Tb4b4b4{Te6edf3tagTb4b4b4, Tb4b4b4{Te6edf3OSTff7b72:Tff7b72:Te6edf3timeTb4b4b4(Tb4b4b4)Tb4b4b4, Te6edf3announce_dataTb4b4b4}Tb4b4b4}Tb4b4b4)Tb4b4b4;
Tb4b4b4}
T8b949e//TRACE("Destination::announce: announce_data:" + announce_data.toHex());
Te6edf3TypeTff7b72:Tff7b72:Te6edf3PacketTff7b72:Tff7b72:Te6edf3context_types Te6edf3announce_context Tff7b72= Te6edf3TypeTff7b72:Tff7b72:Te6edf3PacketTff7b72:Tff7b72:Te6edf3CONTEXT_NONETb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3path_responseTb4b4b4) Tb4b4b4{
Te6edf3announce_context Tff7b72= Te6edf3TypeTff7b72:Tff7b72:Te6edf3PacketTff7b72:Tff7b72:Te6edf3PATH_RESPONSETb4b4b4;
Tb4b4b4}
T8b949e//TRACE("Destination::announce: creating announce packet...");
T8b949e//p announce_packet = RNS.Packet(self, announce_data, RNS.Packet.ANNOUNCE, context = announce_context, attached_interface = attached_interface)
T8b949e//Packet announce_packet(*this, announce_data, Type::Packet::ANNOUNCE, announce_context, Type::Transport::BROADCAST, Type::Packet::HEADER_1, nullptr, attached_interface);
Te6edf3Packet Te6edf3announce_packetTb4b4b4(Tff7b72*Tff7b72thisTb4b4b4, Te6edf3attached_interfaceTb4b4b4, Te6edf3announce_dataTb4b4b4, Te6edf3TypeTff7b72:Tff7b72:Te6edf3PacketTff7b72:Tff7b72:Te6edf3ANNOUNCETb4b4b4, Te6edf3announce_contextTb4b4b4, Te6edf3TypeTff7b72:Tff7b72:Te6edf3TransportTff7b72:Tff7b72:Te6edf3BROADCASTTb4b4b4, Te6edf3TypeTff7b72:Tff7b72:Te6edf3PacketTff7b72:Tff7b72:Te6edf3HEADER_1Tb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3sendTb4b4b4) Tb4b4b4{
Te6edf3TRACETb4b4b4(Ta5d6ff"Ta5d6ffDestination::announce: sending announce packet...Ta5d6ff"Tb4b4b4)Tb4b4b4;
Te6edf3announce_packetTb4b4b4.Te6edf3sendTb4b4b4(Tb4b4b4)Tb4b4b4;
Tff7b72return Tb4b4b4{Te6edf3TypeTff7b72:Tff7b72:Te6edf3NONETb4b4b4}Tb4b4b4;
Tb4b4b4}
Tff7b72else Tb4b4b4{
Tff7b72return Te6edf3announce_packetTb4b4b4;
Tb4b4b4}
Tb4b4b4}
Te6edf3Packet Te6edf3DestinationTff7b72:Tff7b72:Te6edf3announceTb4b4b4(Tff7b72const Te6edf3BytesTff7b72& Te6edf3app_data T8b949e/*= {}*/Tb4b4b4, Tffa657bool Te6edf3path_response T8b949e/*= false*/Tb4b4b4) Tb4b4b4{
Tff7b72return Te6edf3announceTb4b4b4(Te6edf3app_dataTb4b4b4, Te6edf3path_responseTb4b4b4, Tb4b4b4{Te6edf3TypeTff7b72:Tff7b72:Te6edf3NONETb4b4b4}Tb4b4b4)Tb4b4b4;
Tb4b4b4}
T8b949e/*
Registers a request handler.
:param path: The path for the request handler to be registered.
:param response_generator: A function or method with the signature *response_generator(path, data, request_id, link_id, remote_identity, requested_at)* to be called. Whatever this funcion returns will be sent as a response to the requester. If the function returns ``None``, no response will be sent.
:param allow: One of ``RNS.Destination.ALLOW_NONE``, ``RNS.Destination.ALLOW_ALL`` or ``RNS.Destination.ALLOW_LIST``. If ``RNS.Destination.ALLOW_LIST`` is set, the request handler will only respond to requests for identified peers in the supplied list.
:param allowed_list: A list of *bytes-like* :ref:`RNS.Identity<api-identity>` hashes.
:raises: ``ValueError`` if any of the supplied arguments are invalid.
*/
T8b949e/*
void Destination::register_request_handler(const Bytes& path, response_generator = None, request_policies allow = ALLOW_NONE, allowed_list = None) {
if path == None or path == "":
raise ValueError("Invalid path specified")
elif not callable(response_generator):
raise ValueError("Invalid response generator specified")
elif not allow in Destination.request_policies:
raise ValueError("Invalid request policy")
else:
path_hash = RNS.Identity.truncated_hash(path.encode("utf-8"))
request_handler = [path, response_generator, allow, allowed_list]
self.request_handlers[path_hash] = request_handler
}
*/
T8b949e/*
Deregisters a request handler.
:param path: The path for the request handler to be deregistered.
:returns: True if the handler was deregistered, otherwise False.
*/
T8b949e/*
bool Destination::deregister_request_handler(const Bytes& path) {
path_hash = RNS.Identity.truncated_hash(path.encode("utf-8"))
if path_hash in self.request_handlers:
self.request_handlers.pop(path_hash)
return True
else:
return False
}
*/
Tffa657void Te6edf3DestinationTff7b72:Tff7b72:Te6edf3receiveTb4b4b4(Tff7b72const Te6edf3PacketTff7b72& Te6edf3packetTb4b4b4) Tb4b4b4{
Te6edf3assertTb4b4b4(Te6edf3_objectTb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3packetTb4b4b4.Te6edf3packet_typeTb4b4b4(Tb4b4b4) Tff7b72=Tff7b72= Te6edf3TypeTff7b72:Tff7b72:Te6edf3PacketTff7b72:Tff7b72:Te6edf3LINKREQUESTTb4b4b4) Tb4b4b4{
Te6edf3Bytes Td2a8ffplaintextTb4b4b4(Te6edf3packetTb4b4b4.Te6edf3dataTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4;
Te6edf3incoming_link_requestTb4b4b4(Te6edf3plaintextTb4b4b4, Te6edf3packetTb4b4b4)Tb4b4b4;
Tb4b4b4}
Tff7b72else Tb4b4b4{
T8b949e// CBA TODO Why isn't the Packet decrypting itself?
Te6edf3Bytes Td2a8ffplaintextTb4b4b4(Te6edf3decryptTb4b4b4(Te6edf3packetTb4b4b4.Te6edf3dataTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4)Tb4b4b4;
T8b949e//TRACE("Destination::receive: decrypted data: " + plaintext.toHex());
Tff7b72if Tb4b4b4(Te6edf3plaintextTb4b4b4) Tb4b4b4{
Tff7b72if Tb4b4b4(Te6edf3packetTb4b4b4.Te6edf3packet_typeTb4b4b4(Tb4b4b4) Tff7b72=Tff7b72= Te6edf3TypeTff7b72:Tff7b72:Te6edf3PacketTff7b72:Tff7b72:Te6edf3DATATb4b4b4) Tb4b4b4{
Tff7b72if Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_callbacksTb4b4b4.Te6edf3_packetTb4b4b4) Tb4b4b4{
Tff7b72try Tb4b4b4{
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_callbacksTb4b4b4.Te6edf3_packetTb4b4b4(Te6edf3plaintextTb4b4b4, Te6edf3packetTb4b4b4)Tb4b4b4;
Tb4b4b4}
Tff7b72catch Tb4b4b4(Te6edf3stdTff7b72:Tff7b72:Te6edf3exceptionTff7b72& Te6edf3eTb4b4b4) Tb4b4b4{
Te6edf3DEBUGTb4b4b4(Ta5d6ff"Ta5d6ffError while executing receive callback from Ta5d6ff" Tff7b72+ Te6edf3toStringTb4b4b4(Tb4b4b4) Tff7b72+ Ta5d6ff"Ta5d6ff. The contained exception was: Ta5d6ff" Tff7b72+ Te6edf3eTb4b4b4.Te6edf3whatTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tffa657void Te6edf3DestinationTff7b72:Tff7b72:Te6edf3incoming_link_requestTb4b4b4(Tff7b72const Te6edf3BytesTff7b72& Te6edf3dataTb4b4b4, Tff7b72const Te6edf3PacketTff7b72& Te6edf3packetTb4b4b4) Tb4b4b4{
Te6edf3assertTb4b4b4(Te6edf3_objectTb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_accept_link_requestsTb4b4b4) Tb4b4b4{
Te6edf3TRACETb4b4b4(Ta5d6ff"Ta5d6ff***** Accepting link requestTa5d6ff"Tb4b4b4)Tb4b4b4;
Te6edf3RNSTff7b72:Tff7b72:Te6edf3Link Te6edf3link Tff7b72= Te6edf3LinkTff7b72:Tff7b72:Te6edf3validate_requestTb4b4b4(Tff7b72*Tff7b72thisTb4b4b4, Te6edf3dataTb4b4b4, Te6edf3packetTb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3linkTb4b4b4) Tb4b4b4{
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_linksTb4b4b4.Te6edf3insertTb4b4b4(Te6edf3linkTb4b4b4)Tb4b4b4;
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
T8b949e/*
Encrypts information for ``RNS.Destination.SINGLE`` or ``RNS.Destination.GROUP`` type destination.
:param plaintext: A *bytes-like* containing the plaintext to be encrypted.
:raises: ``ValueError`` if destination does not hold a necessary key for encryption.
*/
T8b949e/*virtual*/ Tff7b72const Te6edf3Bytes Te6edf3DestinationTff7b72:Tff7b72:Te6edf3encryptTb4b4b4(Tff7b72const Te6edf3BytesTff7b72& Te6edf3dataTb4b4b4) Tb4b4b4{
Te6edf3assertTb4b4b4(Te6edf3_objectTb4b4b4)Tb4b4b4;
Te6edf3TRACETb4b4b4(Ta5d6ff"Ta5d6ffDestination::encrypt: encrypting data...Ta5d6ff"Tb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_type Tff7b72=Tff7b72= Te6edf3PLAINTb4b4b4) Tb4b4b4{
Tff7b72return Te6edf3dataTb4b4b4;
Tb4b4b4}
Tff7b72if Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_type Tff7b72=Tff7b72= Te6edf3SINGLE Tff7b72&Tff7b72& Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4) Tb4b4b4{
Tff7b72return Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4.Te6edf3encryptTb4b4b4(Te6edf3dataTb4b4b4)Tb4b4b4;
Tb4b4b4}
T8b949e// TODO
T8b949e/*
if (_object->_type == GROUP {
if hasattr(self, "prv") and self.prv != None:
try:
return self.prv.encrypt(plaintext)
except Exception as e:
RNS.log("The GROUP destination could not encrypt data", RNS.LOG_ERROR)
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
else:
raise ValueError("No private key held by GROUP destination. Did you create or load one?")
}
*/
T8b949e// CBA Reference implementation does not handle this default case
T8b949e// CBA TODO Determine of returning plaintext is appropriate here (for now it's necessary for PROOF packets)
Tff7b72return Te6edf3dataTb4b4b4;
Tb4b4b4}
T8b949e/*
Decrypts information for ``RNS.Destination.SINGLE`` or ``RNS.Destination.GROUP`` type destination.
:param ciphertext: *Bytes* containing the ciphertext to be decrypted.
:raises: ``ValueError`` if destination does not hold a necessary key for decryption.
*/
T8b949e/*virtual*/ Tff7b72const Te6edf3Bytes Te6edf3DestinationTff7b72:Tff7b72:Te6edf3decryptTb4b4b4(Tff7b72const Te6edf3BytesTff7b72& Te6edf3dataTb4b4b4) Tb4b4b4{
Te6edf3assertTb4b4b4(Te6edf3_objectTb4b4b4)Tb4b4b4;
Te6edf3TRACETb4b4b4(Ta5d6ff"Ta5d6ffDestination::decrypt: decrypting data...Ta5d6ff"Tb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_type Tff7b72=Tff7b72= Te6edf3PLAINTb4b4b4) Tb4b4b4{
Tff7b72return Te6edf3dataTb4b4b4;
Tb4b4b4}
Tff7b72if Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_type Tff7b72=Tff7b72= Te6edf3SINGLE Tff7b72&Tff7b72& Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4) Tb4b4b4{
Tff7b72return Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4.Te6edf3decryptTb4b4b4(Te6edf3dataTb4b4b4)Tb4b4b4;
Tb4b4b4}
T8b949e/*
if (_object->_type == GROUP) {
if hasattr(self, "prv") and self.prv != None:
try:
return self.prv.decrypt(ciphertext)
except Exception as e:
RNS.log("The GROUP destination could not decrypt data", RNS.LOG_ERROR)
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
else:
raise ValueError("No private key held by GROUP destination. Did you create or load one?")
}
*/
T8b949e// MOCK
Tff7b72return Tb4b4b4{Te6edf3BytesTff7b72:Tff7b72:Te6edf3NONETb4b4b4}Tb4b4b4;
Tb4b4b4}
T8b949e/*
Signs information for ``RNS.Destination.SINGLE`` type destination.
:param message: *Bytes* containing the message to be signed.
:returns: A *bytes-like* containing the message signature, or *None* if the destination could not sign the message.
*/
T8b949e/*virtual*/ Tff7b72const Te6edf3Bytes Te6edf3DestinationTff7b72:Tff7b72:Te6edf3signTb4b4b4(Tff7b72const Te6edf3BytesTff7b72& Te6edf3messageTb4b4b4) Tb4b4b4{
Te6edf3assertTb4b4b4(Te6edf3_objectTb4b4b4)Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_type Tff7b72=Tff7b72= Te6edf3SINGLE Tff7b72&Tff7b72& Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4) Tb4b4b4{
Tff7b72return Te6edf3_objectTff7b72-Tff7b72>Te6edf3_identityTb4b4b4.Te6edf3signTb4b4b4(Te6edf3messageTb4b4b4)Tb4b4b4;
Tb4b4b4}
Tff7b72return Tb4b4b4{Te6edf3BytesTff7b72:Tff7b72:Te6edf3NONETb4b4b4}Tb4b4b4;
Tb4b4b4}
Tffa657bool Te6edf3DestinationTff7b72:Tff7b72:Te6edf3has_linkTb4b4b4(Tff7b72const Te6edf3LinkTff7b72& Te6edf3linkTb4b4b4) Tb4b4b4{
Te6edf3assertTb4b4b4(Te6edf3_objectTb4b4b4)Tb4b4b4;
Tff7b72return Tb4b4b4(Te6edf3_objectTff7b72-Tff7b72>Te6edf3_linksTb4b4b4.Te6edf3countTb4b4b4(Te6edf3linkTb4b4b4) Tff7b72> T79c0ff0Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Tffa657void Te6edf3DestinationTff7b72:Tff7b72:Te6edf3remove_linkTb4b4b4(Tff7b72const Te6edf3LinkTff7b72& Te6edf3linkTb4b4b4) Tb4b4b4{
Te6edf3assertTb4b4b4(Te6edf3_objectTb4b4b4)Tb4b4b4;
Te6edf3_objectTff7b72-Tff7b72>Te6edf3_linksTb4b4b4.Te6edf3eraseTb4b4b4(Te6edf3linkTb4b4b4)Tb4b4b4;
Tb4b4b4}
Served by rngit 1.4.2 - Generated in 0.04s